package zilla.filesystem;
import java.io.File;

import zilla.useraccounts.*;

public class YAFile extends SystemFile{

	AccountType storedIn;
	String cloudUrl;
	String nameOnCloud;
	File obj;
	
	
	public YAFile(File file)
	{
		this.fileName = file.getName();
		obj = file;
		this.type = FileType.FILE;
	}
	
	public boolean putOnCloud()
	{
		UserAccount acc = zilla.useraccounts.AccountManager.u_accounts.get(this.parentUser);
		CloudAccount cloudAcc = acc.chooseAccount(obj);
		if(cloudAcc != null)
		{
			this.cloudUrl = cloudAcc.putFile(obj);
			this.storedIn = cloudAcc.type;
			 return true;
		}
		return false;
	}
	
	public String downloadAsString(File file)
	{
		UserAccount account = zilla.useraccounts.AccountManager.u_accounts.get(this.parentUser);
		CloudAccount c_acc = account.getCloudAccount(this.storedIn);
		return c_acc.getFileAsString();
	}

	public byte[] downloadAsBytes(File file)
	{
		UserAccount account = zilla.useraccounts.AccountManager.u_accounts.get(this.parentUser);
		CloudAccount c_acc = account.getCloudAccount(this.storedIn);
		return c_acc.getFileAsBytes();
	}
	
}
